package day01_IO_JDBC.demo_JDBC_emp_pro.DBUtil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DButil {
//    定义四个常量
    private static final String DRIVER ="com.mysql.cj.jdbc.Driver";
    private static final String URL="jdbc:mysql://localhost:3306/emp2";
    private static final String username="root";
    private static final String password="123456";

//    加载驱动
    public static Connection getConnection(){
        Connection connection= null;

        try {
            Class.forName(DRIVER);
            connection= DriverManager.getConnection(URL, username, password);
            return connection;

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return connection;

    }

}
